package com.link2room.aeriabots.controller.wxReception;

import com.link2room.aeriabots.dto.param.base.WxComponentParamDto;
import com.link2room.aeriabots.facade.IWXComponentFacadeService;
import com.link2room.sideswipe.permissionResouces.annotation.L2RPermissionResources;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.link2room.aeriabots.constant.PermissionConstant.wxAuthentications;

/**
 * 公众号网页授权授权回调
 * Created by LN on 2016/9/2.
 */
@RestController
@RequestMapping("/Authentications")
public class WxOfficialAccountsAuthorizerRedirectManagerController {
    @Resource
    private IWXComponentFacadeService wxComponentFacadeService;

    @RequestMapping(method = RequestMethod.GET)
    @L2RPermissionResources(value = wxAuthentications,name = "公众号网页授权授权回调")
    public void Redirect(
            @RequestParam(name = "auth_code")String authCode
    ) throws Exception {
        WxComponentParamDto dto = new WxComponentParamDto();
        dto.setAuthCode(authCode);
        wxComponentFacadeService.saveAuthorizerAccessToken(dto);

        System.out.println("authCode:"+authCode);
    }
}
